package com.txzhang.springcloud.orderservice.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.txzhang.springcloud.orderservice.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/json")
    public R<?> json(Integer id) {
        return R.ok(orderService.getById(id));
    }

    @PostMapping("createOrder")
    public R createOrder(Integer userId, String goodCode, Integer count) {
        return R.ok(orderService.createOrder(userId, goodCode, count));
    }
}
